package com.westa.smallshop.cart;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.westa.smallshop.R;
import com.westa.smallshop.common.BaseActivity;
import com.westa.smallshop.data.source.remote.GoodsItemRemoteDataSource;
import com.westa.smallshop.util.ActivityUtils;

/**
 * Created by cy on 10/11/16.
 */

public class CartActivity extends BaseActivity {

    public static void startActivity(Activity activity) {
        Intent intent = new Intent(activity, CartActivity.class);
        activity.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cart);

        CartFragment cartFragment = (CartFragment) getSupportFragmentManager()
                .findFragmentById(R.id.fragment_layout);

        if (cartFragment == null) {
            cartFragment = CartFragment.newInstance();
            ActivityUtils.addFragmentToActivity(getSupportFragmentManager(),
                    cartFragment, R.id.fragment_layout);
        }

        new CartPresenter(cartFragment, new GoodsItemRemoteDataSource(getApplicationContext()));
    }
}
